package org.eCon.maven.plugin.unixBased;

import org.eCon.maven.plugin.AbstractGWTRunPlugin;

import java.io.File;

/**
 *  
 * User: erkink
 * Date: 14-Aug-2008
 * Time: 20:14:02
 *
 */
public abstract class UnixBasedGWTRunPlugin extends AbstractGWTRunPlugin  {

   protected String env_dependent_jar;


    protected String getEnvLib() {
        return env_dependent_jar;
    }

    public void createHostModeScript() {
        StringBuffer sb = new StringBuffer(200);
        sb.append("#!/bin/sh");
        String newline = System.getProperty("line.separator");
        sb.append(newline);
        sb.append(this.createJavaPath());
        sb.append(" ").append(getJVMParam()).append(" -cp ");

        sb.append(this.getClasspath());
        sb.append(" ");
        sb.append(SHELL);
        sb.append(" ");

        this.controlAndAppend(this.gwt_relative_out, "out", sb, true);
        sb.append(" \"$@\" ");
        sb.append(this.gwt_module).append("/").append(getHtmlName(this.gwt_module));

        String filePath = this.currentDir + File.separator + "gwt-shell";
        this.writeToFile(filePath, sb.toString());
    }

    protected abstract String getJarName();

    protected abstract String getJVMParam();

}
